package visaoInterface;

import dao.DaoCliente;
import dao.DaoLocacao;
import dao.DaoMotorista;
import dao.DaoPessoa;
import dao.DaoTipoVeiculo;
import dao.DaoVeiculo;
import java.util.Iterator;
import java.util.Vector;
import javax.swing.JOptionPane;
import javax.swing.JTable;
import javax.swing.ListSelectionModel;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.table.DefaultTableModel;
import modelo.dominio.Cliente;
import modelo.dominio.Locacao;
import modelo.dominio.Pessoa;
import modelo.dominio.TipoVeiculo;
import modelo.dominio.Veiculo;


public class CriaLocacao extends javax.swing.JDialog {
    
    DefaultTableModel tmCliente = new DefaultTableModel(null, new String[]{"Codigo","Nome","Cpf","Rua"} ) {
        @Override
        public boolean isCellEditable(int row, int col)
        {
            return false;
        } 
    };
    
    DefaultTableModel tmVeiculo = new DefaultTableModel(null, new String[]{"Codigo","Nome","Marca","Placa","Cor","Tipo do Veiculo","Taxa Base","Preço por Km"} ) {
        @Override
        public boolean isCellEditable(int row, int col)
        {
            return false;
        } 
    };
   
    Vector<Cliente> pessoas;
    Vector<Veiculo> veiculos;
    ListSelectionModel lsmCliente;
    ListSelectionModel lsmVeiculo;
    int aux = 0;

    
    /** Creates new form CriaLocacao */
    
    public CriaLocacao(java.awt.Dialog parent, boolean modal) {
        super(parent, modal);
        initComponents();
    }
    
    /**
     * mostra na tabela os clientes do vetor que busca no daoClientes.
     * @param pessoas vetor de pessoas.
     */
    public void mostraPesquisaClientes(Vector<Pessoa> pessoas){
        String[] linha = new String[] {null,null,null};
        while(tmCliente.getRowCount()>0){
            tmCliente.removeRow(0);
        }       
            for (int i=0 ; i<pessoas.size() ; i++) {
                tmCliente.addRow(linha);
                tmCliente.setValueAt(pessoas.get(i).getCodCliente(),i,0);
                tmCliente.setValueAt(pessoas.get(i).getNome(),i,1);
                tmCliente.setValueAt(pessoas.get(i).getCpf(),i,2);
                tmCliente.setValueAt(pessoas.get(i).getTelefone(),i,3);
            } 
        if (tmCliente.getRowCount() == 0){
            JOptionPane.showMessageDialog(null, "Registro nao encontrados.");
        }
    }
    /**
     * mostra na tabela os veiculos do vetor buscado no daoVeiculo.
     * @param veiculos vetor de veiculos.
     * @param tipoVeiculos vetor de tipo veiculos.s
     */
    public void mostraPesquisaVeiculo(Vector<Veiculo> veiculos,Vector<TipoVeiculo> tipoVeiculos){
        String[] linha = new String[] {null,null,null,null,null,null,null,null,null,null};
        while(tmVeiculo.getRowCount()>0){
            tmVeiculo.removeRow(0);
        }
            for (int i=0 ; i<veiculos.size() ; i++) {
                tmVeiculo.addRow(linha);
                tmVeiculo.setValueAt(veiculos.get(i).getCodVeiculo(),i,0);
                tmVeiculo.setValueAt(veiculos.get(i).getModelo(),i,1);
                tmVeiculo.setValueAt(veiculos.get(i).getMarca(),i,2);
                tmVeiculo.setValueAt(veiculos.get(i).getPlaca(),i,3);
                tmVeiculo.setValueAt(veiculos.get(i).getCor(),i,4);
                tmVeiculo.setValueAt(tipoVeiculos.get(i).getTipoVeiculo(),i,5);
                tmVeiculo.setValueAt(tipoVeiculos.get(i).getTaxaBase(),i,6);
                tmVeiculo.setValueAt(tipoVeiculos.get(i).getPrecoKm(),i,7);
            } 
        if (tmCliente.getRowCount() == 0){
            JOptionPane.showMessageDialog(null, "Registro nao encontrados.");
       }
    }
    
    
    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jPanel4 = new javax.swing.JPanel();
        jLTipoLocacao = new javax.swing.JLabel();
        jLValorLocacao = new javax.swing.JLabel();
        jTFValorLocacao = new javax.swing.JTextField();
        jLabel8 = new javax.swing.JLabel();
        jLDataSaida = new javax.swing.JLabel();
        jLPrevDias = new javax.swing.JLabel();
        jTFPrevDias = new javax.swing.JTextField();
        jCBTipoLocacao = new javax.swing.JComboBox();
        jFTFData = new javax.swing.JFormattedTextField();
        jBDataAtual = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        jBCadastrarMotorista = new javax.swing.JButton();
        jTFCnh1 = new javax.swing.JFormattedTextField();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        jTFLPesquisa = new javax.swing.JTextField();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTTabela = new javax.swing.JTable();
        jButton1 = new javax.swing.JButton();
        jLabel6 = new javax.swing.JLabel();
        jCCodCliente = new javax.swing.JComboBox();
        jPanel3 = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        jTTabela1 = new javax.swing.JTable();
        jLabel7 = new javax.swing.JLabel();
        jButton2 = new javax.swing.JButton();
        jTFLPesqVeiculos = new javax.swing.JTextField();
        jCCodVeiculo = new javax.swing.JComboBox();
        jLabel9 = new javax.swing.JLabel();
        jBCLLimpar = new javax.swing.JButton();
        jBCLSalvar = new javax.swing.JButton();
        jBCLCancelar = new javax.swing.JButton();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Cadastro de Locação"));
        jPanel1.setLayout(null);

        jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder("Dados da Locação"));
        jPanel4.setLayout(null);

        jLTipoLocacao.setText("Tipo da Locação");
        jPanel4.add(jLTipoLocacao);
        jLTipoLocacao.setBounds(30, 90, 120, 14);

        jLValorLocacao.setText("Valor da Locação");
        jPanel4.add(jLValorLocacao);
        jLValorLocacao.setBounds(30, 360, 140, 14);

        jTFValorLocacao.setEditable(false);
        jTFValorLocacao.setText("Esta locação ainda não foi finalizada");
        jTFValorLocacao.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTFValorLocacaoActionPerformed(evt);
            }
        });
        jPanel4.add(jTFValorLocacao);
        jTFValorLocacao.setBounds(190, 350, 220, 30);

        jLabel8.setText("R$");
        jPanel4.add(jLabel8);
        jLabel8.setBounds(140, 360, 40, 14);

        jLDataSaida.setText("Data de Saída");
        jPanel4.add(jLDataSaida);
        jLDataSaida.setBounds(30, 170, 120, 14);

        jLPrevDias.setText("Previsão de Dias");
        jPanel4.add(jLPrevDias);
        jLPrevDias.setBounds(30, 280, 120, 14);
        jPanel4.add(jTFPrevDias);
        jTFPrevDias.setBounds(190, 280, 220, 30);

        jCBTipoLocacao.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Por Quilometragem", "Quilometragem Livre" }));
        jCBTipoLocacao.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCBTipoLocacaoActionPerformed(evt);
            }
        });
        jPanel4.add(jCBTipoLocacao);
        jCBTipoLocacao.setBounds(150, 90, 160, 30);

        jFTFData.setFormatterFactory(new javax.swing.text.DefaultFormatterFactory(new javax.swing.text.DateFormatter(new java.text.SimpleDateFormat("dd/MM/yyyy"))));
        jFTFData.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jFTFDataActionPerformed(evt);
            }
        });
        jPanel4.add(jFTFData);
        jFTFData.setBounds(190, 170, 220, 30);

        jBDataAtual.setText("Data Atual");
        jBDataAtual.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBDataAtualActionPerformed(evt);
            }
        });
        jPanel4.add(jBDataAtual);
        jBDataAtual.setBounds(300, 210, 110, 23);

        jLabel1.setFont(new java.awt.Font("Tahoma", 0, 9));
        jLabel1.setText("colocar no formato dd/MM/yyyy");
        jPanel4.add(jLabel1);
        jLabel1.setBounds(10, 190, 170, 30);

        jBCadastrarMotorista.setText("Cadastrar Motorista");
        jBCadastrarMotorista.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBCadastrarMotoristaActionPerformed(evt);
            }
        });
        jPanel4.add(jBCadastrarMotorista);
        jBCadastrarMotorista.setBounds(30, 410, 150, 23);
        jPanel4.add(jTFCnh1);
        jTFCnh1.setBounds(-14, 0, 20, 20);

        jLabel2.setText("O motorista habilitado para esta locação será o ultimo motorista ");
        jPanel4.add(jLabel2);
        jLabel2.setBounds(30, 450, 440, 20);

        jLabel3.setText("cadastrado acima.");
        jPanel4.add(jLabel3);
        jLabel3.setBounds(30, 480, 330, 14);

        jPanel1.add(jPanel4);
        jPanel4.setBounds(770, 20, 450, 510);

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder("Dados do Cliente"));

        jTTabela.setModel(tmCliente);
        jScrollPane1.setViewportView(jTTabela);

        jButton1.setText("Pesquisar");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jLabel6.setText("Selecione o código do cliente desejado :");

        jCCodCliente.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCCodClienteActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(139, 139, 139)
                        .addComponent(jLabel6, javax.swing.GroupLayout.PREFERRED_SIZE, 310, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jCCodCliente, javax.swing.GroupLayout.PREFERRED_SIZE, 128, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 695, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addGroup(jPanel2Layout.createSequentialGroup()
                                .addComponent(jTFLPesquisa, javax.swing.GroupLayout.PREFERRED_SIZE, 575, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(18, 18, 18)
                                .addComponent(jButton1)))))
                .addContainerGap(23, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jTFLPesquisa, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButton1))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 118, Short.MAX_VALUE)
                .addGap(18, 18, 18)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6)
                    .addComponent(jCCodCliente, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap())
        );

        jPanel1.add(jPanel2);
        jPanel2.setBounds(10, 20, 740, 230);
        jPanel2.getAccessibleContext().setAccessibleParent(this);

        jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("Dados do Veiculo"));
        jPanel3.setLayout(null);

        jTTabela1.setModel(tmVeiculo);
        jScrollPane2.setViewportView(jTTabela1);

        jPanel3.add(jScrollPane2);
        jScrollPane2.setBounds(20, 80, 700, 130);

        jLabel7.setText("Selecione o código do veiculo desejado :");
        jPanel3.add(jLabel7);
        jLabel7.setBounds(150, 230, 310, 14);

        jButton2.setText("Pesquisar");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });
        jPanel3.add(jButton2);
        jButton2.setBounds(620, 40, 79, 23);

        jTFLPesqVeiculos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTFLPesqVeiculosActionPerformed(evt);
            }
        });
        jPanel3.add(jTFLPesqVeiculos);
        jTFLPesqVeiculos.setBounds(20, 40, 575, 30);

        jCCodVeiculo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jCCodVeiculoActionPerformed(evt);
            }
        });
        jPanel3.add(jCCodVeiculo);
        jCCodVeiculo.setBounds(460, 220, 128, 30);

        jPanel1.add(jPanel3);
        jPanel3.setBounds(10, 260, 740, 270);

        jLabel9.setText("* Campos Obrigatórios");

        jBCLLimpar.setText("Limpar");
        jBCLLimpar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBCLLimparActionPerformed(evt);
            }
        });

        jBCLSalvar.setText("Salvar");
        jBCLSalvar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBCLSalvarActionPerformed(evt);
            }
        });

        jBCLCancelar.setText("Cancelar");
        jBCLCancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jBCLCancelarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 1232, Short.MAX_VALUE)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel9)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 898, Short.MAX_VALUE)
                        .addComponent(jBCLLimpar)
                        .addGap(18, 18, 18)
                        .addComponent(jBCLSalvar)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jBCLCancelar)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 557, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel9)
                    .addComponent(jBCLLimpar)
                    .addComponent(jBCLSalvar)
                    .addComponent(jBCLCancelar))
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jBCLCancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBCLCancelarActionPerformed
        this.dispose();
    }//GEN-LAST:event_jBCLCancelarActionPerformed

    private void jBCLSalvarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBCLSalvarActionPerformed
            if (aux != 0){
            DaoLocacao dl = new DaoLocacao();
            Locacao l = new Locacao();
            Veiculo v = new Veiculo();
            DaoVeiculo dv = new DaoVeiculo();
            DaoMotorista dm = new DaoMotorista();
            l.setKmSaida(dv.buscarObjetoPorCod(Integer.parseInt(jCCodVeiculo.getSelectedItem().toString())).getKmAtual());
            v = dv.buscarObjetoPorCod(Integer.parseInt(jCCodVeiculo.getSelectedItem().toString()));
            System.out.println(v.getCodVeiculo());
            System.out.println(v.getNumeroLocacoes());
            v.setNumeroLocacoes(v.getNumeroLocacoes()+1);
            dv.atualizar(v);
            l.setPrevDias(Integer.parseInt(jTFPrevDias.getText()));
            l.setCodCliente(Integer.parseInt(jCCodCliente.getSelectedItem().toString()));
            l.setCodMotorista(dm.retornaCodUltimoRegistro());
            l.setCodVeiculo(Integer.parseInt(jCCodVeiculo.getSelectedItem().toString()));
            l.setDataSaida(jFTFData.getText());
            l.setTipoLocacao(jCBTipoLocacao.getSelectedItem().toString());
            dl.insere(l);
            this.dispose();
            }else{
               JOptionPane.showMessageDialog(null, "Favor cadastrar motorista."); 
            }
    }//GEN-LAST:event_jBCLSalvarActionPerformed

    private void jBCLLimparActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBCLLimparActionPerformed
        jTFValorLocacao.setText("");
        jTFPrevDias.setText("");
    }//GEN-LAST:event_jBCLLimparActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        DaoPessoa dp = new DaoPessoa();
        Vector<Pessoa> resultados = new Vector<Pessoa>();
        resultados = dp.buscarClientePorNome(jTFLPesquisa.getText());
        this.mostraPesquisaClientes(resultados);
        this.jCCodCliente.removeAllItems();
        for (Iterator<Pessoa> iterator = resultados.iterator(); iterator.hasNext();) {  
            Pessoa p = iterator.next();
            this.jCCodCliente.addItem(p.getCodCliente());
          }
    }//GEN-LAST:event_jButton1ActionPerformed

    private void jCCodClienteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCCodClienteActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jCCodClienteActionPerformed

    private void jCCodVeiculoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCCodVeiculoActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jCCodVeiculoActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        DaoVeiculo dv = new DaoVeiculo();
        DaoTipoVeiculo dtv = new DaoTipoVeiculo();
        Vector<Veiculo> resultados = new Vector<Veiculo>();
        Vector<TipoVeiculo> resultados_ = new Vector<TipoVeiculo>();
        resultados = dv.buscarVeiculoDisponiveisPorNome(jTFLPesqVeiculos.getText());
        resultados_ = dtv.buscarTipoDeDeterminadoVeiculo(resultados);
        this.jCCodVeiculo.removeAllItems();
        this.mostraPesquisaVeiculo(resultados,resultados_);
        for (Iterator<Veiculo> iterator = resultados.iterator(); iterator.hasNext();) {  
            Veiculo v = iterator.next();
            this.jCCodVeiculo.addItem(v.getCodVeiculo());
          }
    }//GEN-LAST:event_jButton2ActionPerformed

    private void jTFLPesqVeiculosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTFLPesqVeiculosActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jTFLPesqVeiculosActionPerformed

    private void jCBTipoLocacaoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCBTipoLocacaoActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jCBTipoLocacaoActionPerformed

    private void jTFValorLocacaoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTFValorLocacaoActionPerformed

    }//GEN-LAST:event_jTFValorLocacaoActionPerformed

    private void jFTFDataActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jFTFDataActionPerformed

    }//GEN-LAST:event_jFTFDataActionPerformed

    private void jBDataAtualActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBDataAtualActionPerformed
        String data = (new java.text.SimpleDateFormat("dd/MM/yyyy").format(new java.util.Date(System.currentTimeMillis())));
        jFTFData.setText(data);
    }//GEN-LAST:event_jBDataAtualActionPerformed

private void jBCadastrarMotoristaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jBCadastrarMotoristaActionPerformed
       
        ChamaMotorista cm = new ChamaMotorista(this, true);
        cm.setVisible(true);
        aux++;

}//GEN-LAST:event_jBCadastrarMotoristaActionPerformed

    
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(CriaLocacao.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(CriaLocacao.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(CriaLocacao.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(CriaLocacao.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the dialog */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                CriaLocacao dialog = new CriaLocacao(new javax.swing.JDialog(), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {

                    @Override
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jBCLCancelar;
    private javax.swing.JButton jBCLLimpar;
    private javax.swing.JButton jBCLSalvar;
    private javax.swing.JButton jBCadastrarMotorista;
    private javax.swing.JButton jBDataAtual;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JComboBox jCBTipoLocacao;
    private javax.swing.JComboBox jCCodCliente;
    private javax.swing.JComboBox jCCodVeiculo;
    private javax.swing.JFormattedTextField jFTFData;
    private javax.swing.JLabel jLDataSaida;
    private javax.swing.JLabel jLPrevDias;
    private javax.swing.JLabel jLTipoLocacao;
    private javax.swing.JLabel jLValorLocacao;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JFormattedTextField jTFCnh1;
    private javax.swing.JTextField jTFLPesqVeiculos;
    private javax.swing.JTextField jTFLPesquisa;
    private javax.swing.JTextField jTFPrevDias;
    private javax.swing.JTextField jTFValorLocacao;
    private javax.swing.JTable jTTabela;
    private javax.swing.JTable jTTabela1;
    // End of variables declaration//GEN-END:variables
}
